package system.student.login.impl;


import system.student.entity.user.Teacher;
import system.student.entity.user.UserInfo;
import system.student.entity.user.UserType;
import system.student.login.SignupStrategy;
import system.student.mapper.TeacherMapper;
import system.student.mapper.UserMapper;
import system.student.util.MapperUtil;
import java.util.Scanner;


public class TeacherSignupStrategyImpl implements SignupStrategy {

    private static final TeacherMapper teacherMapper = MapperUtil.getMapper(TeacherMapper.class);;
    private static final UserMapper userMapper = MapperUtil.getMapper(UserMapper.class);

    @Override
    public void signup(UserInfo userInfo) {
        String name, department=null;
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入老师的基本信息：1.教师姓名");
        name = scanner.nextLine();
        Teacher teacher =
                new Teacher(userInfo, name, department);
        userMapper.register(userInfo);
        Long userId = userInfo.getId();
        teacher.setUserId(userId);
        teacherMapper.register(teacher);
        System.out.println("老师用户注册成功");
    }

    @Override
    public UserType getUserType() {
        return UserType.Teacher;
    }
}
